import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {


	public static void main(String[] args) {
		
		Set<String> word=new TreeSet<>();
		Map<String,Integer> amount=new HashMap<String,Integer>();
		Scanner sc=new Scanner(System.in );
		int i=0;
		while(true) {
			String str=sc.next();
			if(str.equals("!!!!!"))
				break;
			if(word.add(str)==false) {
				if(amount.containsKey(str)) {
					Integer x=amount.get(str);
					amount.put(str, ++x);
					
				}
				else amount.put(str, 2);
			}	
		}
		System.out.println(word.size());
		List<Entry<String,Integer>> list = new ArrayList<Entry<String,Integer>>(amount.entrySet());
		Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {  
	    public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {    
		        if(o1.getValue()==o2.getValue())
		        	return o1.getKey().compareTo(o2.getKey());
		        else return (o2.getValue() - o1.getValue());
		    }  
		});  
		if(list.size()<=10)
		for(int j=0;j<list.size();j++)
			System.out.println(list.get(j));
		else {
			for(int j=0;j<10;j++)
			System.out.println(list.get(j));
		}
	}


}